﻿// -------------------------------------------------------------------------------------------------
// <copyright file="TVSeason.cs" company="HeterogeneousComputing.com">
// Creative Commons Attribution-ShareAlike 3.0 Unported License
// </copyright>
//
// <author>Jock</author>
//
// <date>04/08/2011</date>
//
// <summary>Implements the tv season class</summary>
// -------------------------------------------------------------------------------------------------
namespace TheTVDBScraper
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization; 
    using System.Text;
    using System.Xml;

    /// <summary>
    /// Class representing a particular Season of a TVSeries.
    /// </summary>
    [DataContract(Name = "TVSeason",
        Namespace = "http://www.heterogeneouscomputing.com/TheTVDBScraper", IsReference = true)]
    public class TVSeason : IExtensibleDataObject
    {
        #region Private Fields
            /// <summary> The extension data object value. </summary>
            private ExtensionDataObject extensionDataObject_value;

            /// <summary>
            /// The unique Id for this TVSeason.
            /// </summary>
            private string id;

            /// <summary>
            /// Attribute that captures the known Episodesfor this Season.
            /// </summary>
            private System.Collections.Generic.Dictionary<string, TVEpisode> episodeDictionary =
                new Dictionary<string, TVEpisode>();
        #endregion

        #region Construtors

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Initializes a new instance of the TVSeason class. </summary>
            /// <param name="seasonId"> Identifier for the season. </param>
            /// -------------------------------------------------------------------------------------------------
            internal TVSeason(string seasonId)
            {
                this.id = seasonId;
            }

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Prevents a default instance of the TVSeason class from being created. </summary>
            /// -------------------------------------------------------------------------------------------------
            private TVSeason()
            {
            }
        #endregion

        #region Properties

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets or sets the structure that contains extra data. 
            /// To implement the IExtensibleDataObject interface,
            /// you must implement the ExtensionData property. The property
            /// holds data from future versions of the class for backward
            /// compatibility.</summary>
            /// <value> Information describing the extension. </value>
            /// ### <returns>
            /// An <see cref="T:System.Runtime.Serialization.ExtensionDataObject" /> that contains data that
            /// is not recognized as belonging to the data contract.
            /// </returns>
            /// -------------------------------------------------------------------------------------------------
            public ExtensionDataObject ExtensionData
            {
                get
                {
                    return this.extensionDataObject_value;
                }

                set
                {
                    this.extensionDataObject_value = value;
                }
            }

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets or sets the identifier. </summary>
            /// <value> The identifier. </value>
            /// -------------------------------------------------------------------------------------------------
            [DataMember]
            public string Id
            {
                get
                {
                    return this.id;
                }

                set
                {
                    this.id = value;
                }
            }

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets a list of the TVEpisodes for this TVSeason. </summary>
            /// <remarks>    The method author was Jock, on the 05/08/2011. </remarks>
            /// <returns>   The episodes. </returns>
            /// -------------------------------------------------------------------------------------------------
            [DataMember]
            public List<TVEpisode> Episodes
            {
                get
                {
                    return this.episodeDictionary.Values.ToList();
                }
            }
        #endregion

        #region Public Operations

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets a list of the TVEpisodes for this TVSeason. </summary>
            /// <remarks>    The method author was Jock, on the 05/08/2011. </remarks>
            /// <returns>   The episodes. </returns>
            /// -------------------------------------------------------------------------------------------------
            public List<TVEpisode> GetEpisodes()
            {
                return this.episodeDictionary.Values.ToList();
            }
        #endregion

        #region Internal Operations

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Adds a TVEpisode object to this TVSeason object.  </summary>
            /// <remarks>    The method author was Jock, on the 05/08/2011. </remarks>
            /// <param name="episode">  The episode. </param>
            /// -------------------------------------------------------------------------------------------------
            internal void AddEpisode(TVEpisode episode)
            {
                if (!this.episodeDictionary.ContainsKey(episode.Id))
                {
                    this.episodeDictionary.Add(episode.Id, episode);
                }
            }
        #endregion
    }
}

/// -------------------------------------------------------------------------------------------------
// End of TVSeason.cs
/// -------------------------------------------------------------------------------------------------
